package acwing.模拟;

import java.util.Scanner;

/**
 * 拉马车
 *
 * @author yang
 * @date 2021/12/12
 */
public class 拉马车 {

    static StringBuffer a;
    static StringBuffer b;
    static StringBuffer c = new StringBuffer(); // 桌上的牌
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String s1 = sc.nextLine();
        a = new StringBuffer(s);
        b = new StringBuffer(s1);
        boolean flagA = true;
        boolean flagB = false;
        while (true) {
            if (flagA) {
                flagA = op(a,c);
                if (a.length() == 0) {
                    System.out.println(b);
                    break;
                }
                flagB = !flagA;
            }
            if (flagB) {
                flagB = op(b, c);
                if (b.length() == 0) {
                    System.out.println(a);
                    break;
                }
                flagA = !flagB;
            }
        }
    }

    private static boolean op(StringBuffer x, StringBuffer c) {
        if (x.length() == 0) return false;
        boolean ans = true;
        char c1 = x.charAt(0);
        int i = c.indexOf(c1 + "");
        // 说明桌上有相同的牌
        if (i != -1) {
            x.append(c1);
            for (int j = 0; j <= i; j++) {
                x.append(c.charAt(j));
            }
            c.delete(0,i + 1);
        } else {
            // 直接打出
            c.insert( 0, c1);
            ans = false;
        }
        // 删除打出的牌
        x.deleteCharAt(0);
        return ans;
    }
}
